---
id: scale-fade-in-out
title: Scale Fade In Out
sidebar_label: Scale Fade In Out
description: Scale Fade In Out animation
keywords:
  - custom-animations
  - scale-fade-in-out
  - carousel animation
  - carousel animation scale-fade-in-out
  - react-native-reanimated-carousel
  - reanimated-carousel
  - reanimated carousel
  - react-native
  - snap-carousel
  - react native
  - snap carousel
  - ios
  - android
  - carousel
  - snap
  - reanimated
image:
slug: /examples/custom-animations/scale-fade-in-out
---

{/* 

=========================================================================
=========================================================================
This page generated by /scripts/gen-pages.mjs, Don't update it manually 
=========================================================================
=========================================================================

*/}

import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
import Demo from '@/components/Demo'

<Callout type="info" emoji="💡">
  Check out the `scale-fade-in-out` animation demo for the full source code [here](https://github.com/dohooo/react-native-reanimated-carousel/blob/main/example/app/app/demos/custom-animations/scale-fade-in-out/index.tsx)
</Callout>

<Demo kind="custom-animations" name="scale-fade-in-out" />

```tsx copy
import * as React from "react";
import { View } from "react-native";
import { interpolate } from "react-native-reanimated";
import Carousel, { TAnimationStyle } from "react-native-reanimated-carousel";

import { SBItem } from "@/components/SBItem";
import { window } from "@/constants/sizes";

const PAGE_WIDTH = window.width;

function Index() {
	const animationStyle: TAnimationStyle = React.useCallback((value: number) => {
		"worklet";

		const zIndex = interpolate(value, [-1, 0, 1], [10, 20, 30]);
		const scale = interpolate(value, [-1, 0, 1], [1.25, 1, 0.25]);
		const opacity = interpolate(value, [-0.75, 0, 1], [0, 1, 0]);

		return {
			transform: [{ scale }],
			zIndex,
			opacity,
		};
	}, []);

	return (
		<View
			id="carousel-component"
			dataSet={{ kind: "custom-animations", name: "scale-fade-in-out" }}
		>
			<Carousel
				loop
				style={{
					width: PAGE_WIDTH,
					height: 240,
					justifyContent: "center",
					alignItems: "center",
				}}
				autoPlay
				width={PAGE_WIDTH * 0.7}
				height={240 * 0.7}
				data={[...new Array(6).keys()]}
				renderItem={({ index }) => {
					return <SBItem key={index} index={index} />;
				}}
				customAnimation={animationStyle}
			/>
		</View>
	);
}

export default Index;

```